﻿using Mohe.Scada.Util.Models;

namespace Mohe.Scada.Util.Attr
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Field, Inherited = true)]
    public class SubAttribute : Attribute
    {
        /// <summary>
        /// 前缀
        /// </summary>
        public string Prefix { get; set; } = string.Empty;
        public string Key { get; set; } = "Id";

        public EnumProtectType ProtectType { get; set; } = EnumProtectType.ReadWrite;
        public SubAttribute()
        {
            this.Prefix = string.Empty;
        }

        public SubAttribute(EnumProtectType protectType)
        {
            this.ProtectType = protectType;
        }
        public SubAttribute(string prefix)
        {
            this.Prefix = prefix;
        }

        public SubAttribute(string prefix, string key)
        {
            this.Prefix = prefix;
            this.Key = key;
        }

        public string FieldName { get; set; }
        public string VarName { get; set; }
        public Type TypeName { get; set; }
        public object Model { get; set; }

        public bool IsWarning { get; set; } = false;
        public string ErrorMessage { get; set; }

        public string Same { get; set; } = string.Empty;
    }
}
